home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / lib / OkScrolledList.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  5.5 KB  |  163 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. ///////////////////////////////////////////////////
  18. // OkScrolledList.h
  19. ///////////////////////////////////////////////////
  20. #ifndef OKSCROLLEDLIST_H
  21. #define OKSCROLLEDLIST_H
  22.  
  23. #include "OkComponent.h"
  24.  
  25. #include "OkStrArray.h"
  26.  
  27. #include <Vk/VkListSearch.h>
  28.  
  29. #include <Xm/List.h>
  30.  
  31.  
  32. class OkScrolledList : public OkComponent {
  33.  
  34.  private:
  35.   CALLBACKSTUB( OkScrolledList, browseSelection );
  36.   CALLBACKSTUB( OkScrolledList, defaultAction );
  37.   CALLBACKSTUB( OkScrolledList, extendedSelection );
  38.   CALLBACKSTUB( OkScrolledList, multipleSelection );
  39.   CALLBACKSTUB( OkScrolledList, singleSelection );
  40.  
  41.   void build( Widget parent, const char* name, Widget srchText=NULL,
  42.               ArgList list=NULL, Cardinal count=0 );
  43.  
  44.   // Search stuff.
  45.   VkListSearch *_listSearch;
  46.   Widget     _searchText;
  47.  
  48.  protected:
  49.   // Callbacks.  Derived class will override these funcs to do 
  50.   // something useful.
  51.   virtual void browseSelection() {}
  52.   virtual void defaultAction() {}
  53.   virtual void extendedSelection() {}
  54.   virtual void multipleSelection() {}
  55.   virtual void singleSelection() {}
  56.  
  57.   VkListSearch* listSearch() { return _listSearch; }
  58.  
  59.  public:
  60.   OkScrolledList( const char* name, Widget parent, Widget srchText=NULL,
  61.           ArgList list=NULL, Cardinal count=0 );
  62.   OkScrolledList( const char* name, Widget parent, OkStrArray& items,
  63.           Widget srchText=NULL );
  64.   virtual ~OkScrolledList() { delete _listSearch; }
  65.   virtual const char* className() { return "OkScrolledList"; }
  66.  
  67.   int itemCount() const;
  68.   int selectedItemCount();
  69.  
  70.  
  71.   // Add Items.
  72.   void addItem( XmString item, int pos=0, Boolean unselected=True );
  73.   void addItem( const char* item, int pos=0, Boolean unselected=True )
  74.     { addItem( (XmString) OkCompoundString( item ), pos, unselected ); }
  75.   void addItems( XmString* items, int itemCount,
  76.         int pos=0, Boolean unselected=True );
  77.   void addItems( const char** items, int itemCount,
  78.         int pos=0, Boolean unselected=True );
  79.  
  80.   void addItems( OkStrArray& items, int pos=0, Boolean unselected=True );
  81.  
  82.  
  83.   // Delete items.
  84.   void deleteAllItems()           { XmListDeleteAllItems( _baseWidget ); }
  85.  
  86.   void deleteItem( XmString item )    { XmListDeleteItem( _baseWidget, item ); }
  87.   void deleteItem( const char* item ) 
  88.     { deleteItem( (XmString) OkCompoundString( item ) ); }
  89.   void deleteItem( int pos )           { deleteItems( pos ); }
  90.  
  91.   void deleteItems( XmString* items, int itemCount )
  92.     { XmListDeleteItems( _baseWidget, items, itemCount ); }
  93.   void deleteItems( const char** items, int itemCount );
  94.   void deleteItems( OkStrArray& items );
  95.   void deleteItems( int pos, int itemCount=1 )
  96.     { XmListDeleteItemsPos( _baseWidget, itemCount, pos ); }
  97.   void deleteItems( int* posList, int itemCount )
  98.     { XmListDeletePositions( _baseWidget, posList, itemCount ); }
  99.  
  100.   void deleteLastItem() { deleteItem( 0 ); }
  101.  
  102.  
  103.   // Replace items.
  104.   void replaceItem( XmString item, int atPos, Boolean unselected=TRUE );
  105.   void replaceItem( const char* item, int atPos, Boolean unselected=TRUE )
  106.     { replaceItem( XmString( OkCompoundString( item ) ), atPos, unselected ); }
  107.   void replaceItems( OkStrArray& items, int atPos, Boolean unselected=TRUE );
  108.  
  109.  
  110.   // Select items.
  111.   void selectItem( XmString item, Boolean notify=True )
  112.     { XmListSelectItem( _baseWidget, item, notify ); }
  113.   void selectItem( const char* item, Boolean notify=True )
  114.     { selectItem( (XmString) OkCompoundString( item ), notify ); } 
  115.   void selectItem( unsigned pos, Boolean notify=True )
  116.     { XmListSelectPos( _baseWidget, pos, notify ); }
  117.  
  118.  
  119.   // Deselect items.
  120.   void deselectAllItems() 
  121.     { XmListDeselectAllItems( _baseWidget ); }
  122.  
  123.   void deselectItem( XmString item ) 
  124.     { XmListDeselectItem( _baseWidget, item ); }
  125.   void deselectItem( const char* item ) 
  126.     { deselectItem( (XmString) OkCompoundString( item ) ); }
  127.   void deselectItem( int pos ) 
  128.     { XmListDeselectPos( _baseWidget, pos ); }
  129.  
  130.  
  131.   // Get selected items.
  132.   int getSelectedItem();
  133.   int getSelectedItems( int **posList );  // Caller needs to free posList.
  134.   int getSelectedItems( OkStrArray* itemList );
  135.  
  136.  
  137.   // Miscelaneous.
  138.   unsigned char selectionPolicy();
  139.   unsigned char selectionPolicy( unsigned char policy );
  140.  
  141.   void firstVisibleItem( XmString item ) { XmListSetItem( _baseWidget, item ); }
  142.   void firstVisibleItem( unsigned pos )  { XmListSetPos( _baseWidget, pos ); }
  143.  
  144.   void lastVisibleItem( XmString item )  
  145.     { XmListSetBottomItem( _baseWidget, item ); }
  146.   void lastVisibleItem( int pos )  
  147.     { XmListSetBottomPos( _baseWidget, pos ); }
  148.  
  149.   int getKbdItemPos() { return XmListGetKbdItemPos( _baseWidget ); }
  150.  
  151.   unsigned findItem( XmString item ) 
  152.     { return XmListItemPos( _baseWidget, item ); }
  153.  
  154.   Boolean isItemSelected( unsigned pos )
  155.     { return XmListPosSelected( _baseWidget, pos ); }
  156.  
  157.   const char* operator[]( unsigned int ) const;
  158.   const char* item( unsigned int i ) const { return (*this)[ i ]; }
  159.  
  160. };
  161.  
  162. #endif
  163.